package com.hhkj.study.api.index.controller;

import com.hhkj.study.api.index.model.req.*;
import com.hhkj.study.api.index.sevice.biz.ApiIndexBizService;
import com.ruoyi.common.core.domain.AjaxResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author luowu
 * @Date 2024/9/29 涵 18:05:24
 */
@RestController
@RequestMapping("/api/index")
public class ApiIndexController {

    @Resource
    private ApiIndexBizService apiIndexBizService;
    /**
     * 轮播列表
     * @return
     */
    @PostMapping("/banner/list")
    public AjaxResult bannerList(@Validated @RequestBody ApiArticleBannerListReq req){
        return AjaxResult.success(apiIndexBizService.bannerList(req));
    }

    /**
     * 字典树列表
     * @param req
     * @return
     */
    @PostMapping("/dict/tree/list")
    public AjaxResult dictTreeList(@Validated @RequestBody ApiDictTreeListReq req){
        return AjaxResult.success(apiIndexBizService.dictTreeList(req));
    }

    /**
     * 商品列表
     * @param req
     * @return
     */
    @PostMapping("/goods/list")
    public AjaxResult goodsList(@RequestBody ApiGoodsListReq req){
        return AjaxResult.success(apiIndexBizService.goodsList(req));
    }

    /**
     * 讲师列表
     * @param req
     * @return
     */
    @PostMapping("/teacher/list")
    public AjaxResult teacherList(@RequestBody ApiTeacherListReq req){
        return AjaxResult.success(apiIndexBizService.teacherList(req));
    }

    /**
     * 宣传语列表
     * @param req
     * @return
     */
    @PostMapping("/welcome/list")
    public AjaxResult welcomeList(@RequestBody ApiWelcomeListReq req){
        return AjaxResult.success(apiIndexBizService.welcomeList(req));
    }

    /**
     * 合作伙伴列表
     * @param req
     * @return
     */
    @PostMapping("/company/list")
    public AjaxResult companyList(@RequestBody ApiCompanyListReq req){
        return AjaxResult.success(apiIndexBizService.companyList(req));
    }

    /**
     * 书籍列表
     * @param req
     * @return
     */
    @PostMapping("/book/list")
    public AjaxResult bookList(@RequestBody ApiBookListReq req){
        return AjaxResult.success(apiIndexBizService.bookList(req));
    }

    /**
     * 友情链接
     * @param req
     * @return
     */
    @PostMapping("/link/list")
    public AjaxResult friendLinkList(@RequestBody ApiFriendLinkListReq req){
        return AjaxResult.success(apiIndexBizService.friendLinkList(req));
    }

    /**
     * 资讯分类列表
     * @return
     */
    @PostMapping("/article/catalog/list")
    public AjaxResult articleCatalogList(){
        return AjaxResult.success(apiIndexBizService.articleCatalogList());
    }


    /**
     * 浏览资讯
     * @return
     */
    @GetMapping("/article/lookup/{id}")
    public AjaxResult lookupArticle(@PathVariable("id") Long id){
        return AjaxResult.success(apiIndexBizService.lookupArticle(id));
    }

    /**
     * 资讯列表
     * @return
     */
    @PostMapping("/exam/article/list")
    public AjaxResult articleList(@Validated @RequestBody ApiArticleListReq req){
        return AjaxResult.success(apiIndexBizService.articleList(req));
    }

    /**
     * 考试流程
     * @return
     */
    @PostMapping("/exam/flow/list")
    public AjaxResult examFlowList(@Validated @RequestBody ApiExamFlowListReq req){
        return AjaxResult.success(apiIndexBizService.examFlowList(req));
    }

    /**
     * 获取基本配置 客服二维码/课程考试时间等
     * @return
     */
    @PostMapping("/config")
    public AjaxResult getConfig(@Validated @RequestBody ApiConfigReq req){
        return AjaxResult.success(apiIndexBizService.getConfig(req));
    }

    /**
     * 获取基本配置
     * @return
     */
    @PostMapping("/base/config")
    public AjaxResult getBaseConfig(@Validated @RequestBody ApiConfigBaseReq req){
        return AjaxResult.success(apiIndexBizService.getBaseConfig(req));
    }


    /**
     * 商品详情中课程详情查看课程结构
     * @return
     */
    @GetMapping(value = {"/course/{id}", "/course"})
    public AjaxResult courseDetail(@PathVariable(value = "id", required = false) Long id) {
        return AjaxResult.success(apiIndexBizService.courseDetail(id));
    }
}
